/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gm.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Med EL MOUDDENE
 */
@Entity
@Table(name = "type_atcd")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TypeAtcd.findAll", query = "SELECT t FROM TypeAtcd t"),
    @NamedQuery(name = "TypeAtcd.findByIdType", query = "SELECT t FROM TypeAtcd t WHERE t.idType = :idType")})
public class TypeAtcd implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_TYPE")
    private Integer idType;
    @Lob
    @Size(max = 65535)
    @Column(name = "LIBELLE")
    private String libelle;
    @JoinColumn(name = "ID_ATCD", referencedColumnName = "ID_ATCD")
    @ManyToOne(optional = false)
    private Atcd idAtcd;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idType")
    private Collection<Caracteristique> caracteristiqueCollection;

    public TypeAtcd() {
    }

    public TypeAtcd(Integer idType) {
        this.idType = idType;
    }

    public Integer getIdType() {
        return idType;
    }

    public void setIdType(Integer idType) {
        this.idType = idType;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public Atcd getIdAtcd() {
        return idAtcd;
    }

    public void setIdAtcd(Atcd idAtcd) {
        this.idAtcd = idAtcd;
    }

    @XmlTransient
    public Collection<Caracteristique> getCaracteristiqueCollection() {
        return caracteristiqueCollection;
    }

    public void setCaracteristiqueCollection(Collection<Caracteristique> caracteristiqueCollection) {
        this.caracteristiqueCollection = caracteristiqueCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idType != null ? idType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TypeAtcd)) {
            return false;
        }
        TypeAtcd other = (TypeAtcd) object;
        if ((this.idType == null && other.idType != null) || (this.idType != null && !this.idType.equals(other.idType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.gm.entities.TypeAtcd[ idType=" + idType + " ]";
    }
    
}
